import React from 'react';
import { Input } from 'antd';
import { AxFormItemBase } from '../lib/AxFormItemBase';
import { AxLabel } from '@/components/AxBase';
import { AxInputProps, AxPasswordProps } from './AxInputProps';

/** 自定义Input */
export const AxInput: React.FC<AxInputProps> = props => {
  const { isLabel = false, ...rest } = props;
  /** 展示为Label */
  const WrappedComponent = isLabel === true ? AxLabel : Input;
  const localProps = {
    autoComplete: 'off',
  };

  return <AxFormItemBase WrappedComponent={WrappedComponent} {...localProps} {...rest} />;
};

const { Password } = Input;
export const AxPassword: React.FC<AxPasswordProps> = props => {
  return <AxFormItemBase {...props} WrappedComponent={Password} />;
};

/** 自定义 margin-bottom:0px 的Input */
export const AxInputNoMarginBottom: React.FC<AxInputProps> = props => {
  return <AxInput formItemClassName="ant-form-item-ax" {...props} />;
};
